<template>
  <div class="myRecommend">
      <div class="no_good">
          <img src="../../assets/icon/common/no_goods.png" alt="">
      </div>


    <div class="title">
        <span class="line"></span>
        <span class="tt_tle">为你推荐</span>
        <span class="line"></span>
    </div>

    <ul class="wrap">
      <li v-for="item in firstList" :key="item.id">
        <a>
          <div class="tt_item" @click="goDetail(item.id)">
            <div class="img">
              <img v-lazy="item.image" alt="" />
            </div>
            <div class="store_name">{{item.store_name}}</div>
            <p class="price">￥<span>{{item.price}}</span></p>
          </div>
        </a>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
    data(){
        return{
            firstList:[]    
        }
    },
    created(){
        this.initData()
    },
    methods:{
        initData(){
          let url = "/api/product/hot?page=1&limit=20"
          let pro = axios.get(url).then(res=>{
              let {status,data} = res.data
              
              if(status == 200 ){
                this.firstList = data
              }

              console.log("获取首页数据成功",res.data)
          }).catch(err=>{
              console.log("获取首页数据失败")
          })
      },

      goDetail(id){
          this.$router.push("/detail/"+id)
      }
    }
    
};
</script>

<style lang="scss" scoped>
.myRecommend{
    padding-bottom: 40px;
    background-color: #fff;
}
.no_good{
    width: 100%;
    height: 230px;
    text-align: center;
    line-height: 210px;
    padding-top: 30px;
    >img{
        width: 233px;
        height: 168px;
    }
}
.title{
    height: 83px;
    display: flex;
    justify-content: center;
    align-items: center;
    .line{
        width: 60px;
        height: 2px;
        background-color: #282828;
    }
    .tt_tle{
        font-size: 14px;
        color: #282828;
        padding: 0 15px;
    }
}
.wrap {
  padding: 0 15px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  li {
    margin-bottom:16px ;
    a {
      display: block;
      .tt_item {
        width: 168px;
        .img{
            width: 100%;
            height: 168px;
            border-radius: 8px;
            overflow: hidden;
            >img{
                width: 100%;
                height: 100%;
            }
        }
        .store_name{
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 14px;
            color: #282828;
            margin-top: 8px;
        }
        .price{
            color: #fc4141;
            font-size: 12px;
            span{
                font-size: 14px;
            }
        }
      }
    }
  }
}
</style>

